package cn.sc.allinpay.allfavour.business.common.adapter;

import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.List;

import cn.pai.common.adapter.BaseRecyAdapter;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.business.common.data.MainMenuData;

/**
 * description：
 * author：pany
 * on 2018/7/17 15:02
 */
public class MainMenuAdapter extends BaseRecyAdapter<MainMenuAdapter.MyViewHoder, MainMenuData> {

    public MainMenuAdapter(List<MainMenuData> datas) {
        super(datas);
    }

    @Override
    public int layoutId() {
        return R.layout.item_main_menu;
    }

    @Override
    public MyViewHoder onCreateViewHolder(View view) {
        return new MyViewHoder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHoder holder, int position, MainMenuData data) {
        holder.tvName.setText(data.getName());
        holder.ivImg.setImageResource(data.getImgId());
    }

    class MyViewHoder extends RecyclerView.ViewHolder {

        AppCompatImageView ivImg;
        AppCompatTextView tvName;

        public MyViewHoder(View itemView) {
            super(itemView);
            // TODO Auto-generated constructor stub
            ivImg = itemView.findViewById(R.id.ivImg);
            tvName = itemView.findViewById(R.id.tvName);
        }
    }
}
